# /usr/bin/python3

# Author: 爱编程的章老师
# @Time: 2021/1/2 0002
# E-mail: Bluesand2010@163.com

# 第三课作业

# 正方形及其内切圆
import sys
from math import pi
import pygame


def rect_circle():
    pygame.init()
    screen = pygame.display.set_mode((800, 600))
    screen.fill((255,255,255))

    # 画正方形
    rect = pygame.Rect(300, 200, 200, 200)
    pygame.draw.rect(screen, (0, 0, 255), rect, width = 1)

    # 画内切圆, 半径因为正方形的线宽占了一个,所以半径要相应的少一个
    pos = 400, 300
    radius = 99
    pygame.draw.circle(screen, (255, 0, 0), pos, radius, )

    pygame.display.update()

    while 1:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                sys.exit()

    pygame.quit()


def circle_rect():
    pygame.init()
    screen = pygame.display.set_mode((800, 600))
    screen.fill((255,255,255))
    # 画外面的圆
    pos = 400, 300
    radius = 101
    pygame.draw.circle(screen, (255, 0, 0), pos, radius, )

    # 画内接正方形
    width = height = 100*1.41  # 计算内接正方形的宽高
    left, top = 400 - width/2, 300-height/2  # 计算内接正方形的左上角坐标
    rect = pygame.Rect(left, top, width, height)
    pygame.draw.rect(screen, (0, 0, 255), rect)
    pygame.display.update()
    while 1:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                sys.exit()

    pygame.quit()

# 画椭圆
def draw_ellipse():
    pygame.init()
    screen = pygame.display.set_mode((800, 600))
    screen.fill((255, 255, 255))

    # 画椭圆
    rect = (100,100,200,100)
    pygame.draw.ellipse(screen, (0,255,255), rect, 1)
    pygame.display.update()

    while 1:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                sys.exit()

    pygame.quit()


def draw_rabbit():
    pygame.init()
    screen = pygame.display.set_mode((800, 600))
    # screen.fill((255, 255, 255))

    # 画兔子脸:以中心为圆心,画半径100的圆
    rect = (300, 200, 100, 100)
    pygame.draw.ellipse(screen, (255, 255, 255), rect)

    # 画兔子左耳朵
    rect = (300, 160, 20, 60)
    pygame.draw.ellipse(screen, (255, 255, 255), rect)

    # 画兔子右耳朵
    rect = (380, 160, 20, 60)
    pygame.draw.ellipse(screen, (255, 255, 255), rect)

    # 画眼睛
    # 画兔子左眼
    rect = (320, 230, 10, 10)
    pygame.draw.ellipse(screen, (255, 0, 0), rect)

    # 画兔子右眼
    rect = (360, 230, 10, 10)
    pygame.draw.ellipse(screen, (255, 0, 0), rect)


    pygame.display.update()

    while 1:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                sys.exit()

    pygame.quit()


def draw_arc():
    pygame.init()
    screen = pygame.display.set_mode((800, 600))
    screen.fill((255, 255, 255))

    # 画椭圆
    rect = (100,100,200,100)
    pygame.draw.arc(screen, (0,255,255), rect, 1.5, -1, width=1)

    rect = (300, 100, 100, 100)
    pygame.draw.arc(screen, (0,0,255), rect, 0, pi/2*3, width=2)

    pygame.display.update()

    while 1:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                sys.exit()

    pygame.quit()




if __name__ == '__main__':
    draw_arc()